package com.whut.rssReader.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListView;

public class MyExpandableListActivity extends MyActivity implements 
       ExpandableListView.OnChildClickListener, ExpandableListView.OnGroupCollapseListener,
       ExpandableListView.OnGroupExpandListener{
	
	protected int expandableListCount;
	protected ExpandableListView expandableListView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	protected void init(){
		setListener();
	}
	
	protected void setListener(){
		expandableListView.setOnChildClickListener(this);
		expandableListView.setOnGroupCollapseListener(this);
		expandableListView.setOnGroupExpandListener(this);
	}
	
	@Override
	public void onGroupExpand(int groupPosition) {
		System.out.println(groupPosition);
		for (int index = 0; index < expandableListCount; ++index) {
			if (groupPosition != index) {
				expandableListView.collapseGroup(index);
			}
		}
	}

	@Override
	public void onGroupCollapse(int groupPosition) {
	}
	
	protected void collapseAllGroup(){
		int size = expandableListCount;
		for (int index = 0; index < size; ++index) {
			expandableListView.collapseGroup(index);
		}
	}

	@Override
	public boolean onChildClick(ExpandableListView parent, View v,
			int groupPosition, int childPosition, long id) {
		return false;
	}	
}
